<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Api\Controller;
use Think\Controller\RestController;

/**
 * api请求接口
 * 
 */
class ButtonMenuController extends RestController {
	
    protected function _initialize()
    {
        $path="./Runtime/Logs/Api/api_".date('Ymd').".log";        
        $data=array($_REQUEST,$_FILES);   
        $logMsg=json_encode($data);
        error_log($logMsg.PHP_EOL,3,$path);
    }
	
	/**
	 * 底部广告
	 * 提交参数方式	post
	 * member 用户id
	 */
	 public function navigation(){
	   
	     $memberId=I('post.memberId','','string');

	     //查询出数据库中的数据 
	     $buttonAc= M('Advertise','cms_')->where(array('id'=>59))->getField('addtime');
	     //判断是否已经将底部导航关闭
	     

	     $where=array('order'=>array('neq',3),'category_id'=>59);
	     $activityContent=M('AdvertiseContent','cms_')->where($where)->order(array('order'))->limit(4)->select();
	    // dump(M('AdvertiseContent','cms_')->getLastSql());exit;
	     $where['order']=3;
	     $mall=M('AdvertiseContent','cms_')->where($where)->find();
	     $activityContent[4]=$activityContent[3];
	     $activityContent[3]=$activityContent[2];
	     $activityContent[2]=$mall;
	     if(!$activityContent || count($activityContent)<4){
	         $this->ajaxReturn(errorReturn('数据有误'));
	     }
	     $data=array();
	     $data['tabId']=intval($buttonAc);
	     foreach ($activityContent as $k=>$v ){
	         $data['tag'][$k]['tabNormal']=add_host_shequ_prefix($v['ch_img']);//导航未选中图标
	         $data['tag'][$k]['tabPressed']=add_host_shequ_prefix($v['en_img']);//导航选中图标
	         $data['tag'][$k]['tabTxt']=$v['title'];//导航文字
	         $data['tag'][$k]['tabUrl']=$v['url'];//导航跳转链接
	         
	     }
	     
	     $this->ajaxReturn(successReturn($data));

	 }
	
}
